package cn.kgc.ssm.controller;

import cn.kgc.ssm.dto.ActivityPageDTO;
import cn.kgc.ssm.entity.Activity;
import cn.kgc.ssm.response.ResponseResult;
import cn.kgc.ssm.service.ActivityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 课工场
 * @date 2024/11/19
 * @description 活动模块
 */
@RestController
@RequestMapping("activity")
public class ActivityController {

    @Autowired
    private ActivityService activityService;


    // 分页
    @GetMapping("page")
    public ResponseResult activityPage(ActivityPageDTO activityPageDTO) {

       return activityService.activityPage(activityPageDTO);
    }


    // 发布活动
    @PostMapping("add")
    public ResponseResult addActivity(@RequestBody Activity activity){

        return activityService.addActivity(activity);

    }


    // 编辑活动  edit
    @PostMapping("edit")
    public ResponseResult editActivity(@RequestBody Activity activity){

        return activityService.editActivity(activity);
    }

    // 删除  delete
    @PostMapping("delete")
    public ResponseResult removeActivity(@RequestBody List<Integer> ids){

        return activityService.removeActivity(ids);
    }


    //   前端网页中最新活动的加载
    @GetMapping("front/list/{limit}")
    public ResponseResult  activityList(@PathVariable("limit") Integer limit){

       return   activityService.activityList(limit);
    }

}
